package com.zxw.service.impl;


import com.aaa.entity.GBrand;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zxw.dao.GBrandMapper;
import com.zxw.service.GBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86176
* @description 针对表【g_brand(品牌)】的数据库操作Service实现
* @createDate 2023-02-28 15:31:27
*/
@Service
@SuppressWarnings("all")
public class GBrandServiceImpl extends ServiceImpl<GBrandMapper, GBrand>
    implements GBrandService {

    @Autowired
    private GBrandMapper gBrandMapper;

    @Override
    public Result findAllBrands(GBrand gbrand, Integer pageCurrent, Integer pageSize) {
        PageHelper.startPage(pageCurrent, pageSize);
        List<GBrand> allBrand = gBrandMapper.findAllBrand(gbrand.getId(), gbrand.getSortid(), gbrand.getStatus());
        PageInfo<GBrand> pageInfo = new PageInfo<>(allBrand);
        return new Result<>(2000,"查询成功",pageInfo);
    }

    @Override
    public Result findAllBrand() {
        QueryWrapper queryWrapper = new QueryWrapper();
        List<GBrand> list = gBrandMapper.selectList(queryWrapper);
        return new Result<>(2000,"查询成功",list);
    }

    @Override
    public Result deleteBrand(Integer id) {
        gBrandMapper.deleteById(id);
        return new Result<>(2000,"删除成功");
    }

    @Override
    public Result updateBrand(GBrand gbrand) {
        gBrandMapper.updateById(gbrand);
        return new Result<>(2000,"修改成功");
    }


}




